import { Injectable } from '@angular/core';
import { Place, PlaceType, PlaceUseLog } from '../models/plactType';
import { BaseService } from './base.service';
@Injectable({
  providedIn: 'root'
})
export class PlaceService extends BaseService {
  queryPlaceUseLogs(params) {
    const url = 'api/placeUseLog';
    return this.get(url, { params });
  }

  delPlaceUseLog(item: PlaceUseLog) {
    const url = 'api/placeUseLog/' + item.id;
    return this.delete(url);
  }
  createPlaceUseLog(data: PlaceUseLog) {
    const url = 'api/placeUseLog';
    return this.post(url, data);
  }
  createPlaceType(data: PlaceType) {
    const url = 'api/placeType';
    return this.post(url, data);
  }

  queryPlaceType(queryParams): Promise<PlaceType[]> {
    const url = 'api/placeType';
    return this.get(url, { params: queryParams });
  }

  delPlaceType(id) {
    const url = 'api/placeType/' + id;
    return this.delete(url);
  }

  updatePlaceType(data: PlaceType) {
    const url = 'api/placeType';
    return this.put(url, data);
  }

  createPlace(data: Place) {
    const url = 'api/place';
    return this.post(url, data);
  }
  updatePlace(data: Place) {
    const url = 'api/place';
    return this.put(url, data);
  }
  deletePlace(id) {
    const url = 'api/place/' + id;
    return this.delete(url);
  }
  queryPlace(queryParams): Promise<Place[]> {
    const url = 'api/place';
    return this.get(url, { params: queryParams });
  }

  getPlaceById(id: string): Promise<Place> {
    const url = 'api/place/' + id;
    return this.get(url);
  }
}
